@extends('admin::layouts.master')
@section('title')
    订单列表
@endsection
@section('tab')

    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-input-inline layui-show-xs-block" style="width: 300px;">
                                <input type="text" name="title" placeholder="名称" value="{{$arr_search['title']}}" autocomplete="off" class="layui-input"></div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="type">
                                    <option value="">类型</option>
                                    <option value="1" @if( $arr_search['type'] == 1  ) selected="" @endif >小程序-首页-banner图</option>
                                    <option value="3" @if( $arr_search['type'] == 3  ) selected="" @endif >用户端-道路救援banner图</option>
                                    <option value="4" @if( $arr_search['type'] == 4  ) selected="" @endif >用户端-首页-活动主页banner</option>
                                    <option value="6" @if( $arr_search['type'] == 6  ) selected="" @endif >用户端-年检维修主页</option>
                                    <option value="5" @if( $arr_search['type'] == 5  ) selected="" @endif >商户端-APP引导页</option>
                                </select>
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i></button>
                                <a class="layui-btn layui-btn-small" style="line-height:1.6em;float:right" onclick="location.reload()" title="刷新">
                                    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                                </a>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body">
                        <button class="layui-btn" onclick="xadmin.open('添加banner','{{route("admin_banner_create")}}')">
                            <i class="layui-icon"></i>添加</button>

                    </div>
                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>名称</th>
                                <th>图片</th>
                                <th>类型</th>
                                <th>链接地址</th>
                                <th>排序</th>
                                <th>状态</th>
                                <th>操作</th></tr>
                            </thead>
                            <tbody>
                                @foreach($data as $key=>$value)
                                <tr class="phono_ine">
                                    <td>{{ $value['id'] }}</td>
                                    <td>{{ $value['title'] }}</td>
                                    <td><img src="{{ $value['img'] }}" style="width: 80px; height: 80px;" title="点击查看大图" class="look_img"></td>
                                    <td>{{ $value['type_msg'] }}</td>
                                    <td>{{ $value['link_url'] }}</td>
                                    <td>{{ $value['sort'] }}</td>
                                    <td><input type="checkbox" name="close" data-id="{{$value['id']}}" data-status="{{$value['status']}}" lay-skin="switch" lay-filter="switchTest" @if( $value['status'] == 1 ) checked="" @endif lay-text="启用|禁用"> </td>
                                    <td class="td-manage">
                                        <a class="layui-btn" title="编辑" onclick="xadmin.open('编辑banner','{{route("admin_banner_edit",["id"=>$value["id"]])}}')" href="javascript:;">
                                            编辑</a>
                                    </td>
                                </tr>
                                @endforeach
                                @if(empty($data))
                                    <td colspan="66" align="center">暂无数据</td>
                                @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
        <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

                //列表点击查看大图
                $("body").on('click','.look_img',function(e){
                    layer.photos({
                        photos: '.phono_ine' //格式见API文档手册页
                        ,anim: 1 //0-6的选择，指定弹出图片动画类型，默认随机
                    });
                })
                
                form.on('switch(switchTest)', function(data){
                    var id = $(this).attr('data-id');
                    var status = 1;
                    if( $(this).attr('data-status') == 1 ){
                        status = 2;
                    }
                    $.ajax({
                        url: js_url('admin-banner-update'),
                        type: 'post',
                        data: {id:id,status:status,'_token': '{{csrf_token()}}'},
                        dataType: "json",
                        success: function (result) {
                            if (result.state === 0) {
                                    layer.msg(result.msg, {time: 500, icon: 6}, function () {
                                });
                            } else {
                                layer.msg(result.msg, {time: 2000, icon: 5});
                            }
                        }
                    });
                });

            })
    </script>
@endsection




